<template>
  <div class="alarmConfiguration zy-content">
    <!-- 模具与设备 -->
    <search :columns="searchData" @getSearch="getSearch(arguments)"></search>
    <div class="alarmConfiguration">
      <div class="list-layout mt16">
        <div class="btns clear">
          <span class="title">{{ $t("common.listInformation") }}</span>
        </div>
        <!-- 表格 -->
        <div class="tableContent">
          <Table
            class="resizable-table"
            border
            @on-column-width-resize="(a,b,c,d)=>{onColumnWidthResize(a,b,c,d,'orderAdjustmentDeviceInfo')}"
            :columns="orderAdjustmentDeviceInfoList"
            ellipsis
            ref="selection"
            stripe
            :data="dataArr"
            @on-selection-change="onSelectChange"
          >
            <template slot-scope="{ row }" slot="action">
              <span class="operationBtn" @click="check(row)">
                <i class="iconfont zy-common-chakan"></i>
                {{ $t('common.Check') }}
              </span>
            </template>
          </Table>
        </div>
        <!-- 分页 -->
        <div class="pageWrap mt16">
          <pageLeftTitle :total="total" :selected="delIds.length" />
          <Page
            :total="total"
            :page-size="pageSize"
            :page-size-opts="pageSizeOption"
            :current="pageNum"
            @on-change="changePageNum"
            @on-page-size-change="changePageSize"
            show-sizer
            show-total
          />
        </div>
      </div>
    </div>
  </div>
</template>
   <!--0 weiguanl  -->
<script>
import {
  getList,
  getLinkList,
  getDeviceNoList,
  deleteApi
} from "@/api/system/equipmentAssociation.js";
import search from "@/components/curd/searchList.vue";
import toggleTableOperation from "@/mixins/toggleTableOperation";
export default {
  name: "associationUser", //仓库配置
  components: { search },
  mixins: [toggleTableOperation],
  data() {
    return {
      test: [],
      //一级搜索
      searchData: [
        {
          title: "工序",
          key: "productionProcessesName"
        }
      ],
      //一级table配置
      columns: [
        {
          key: "selection",
          type: "selection",
          width: 60,
          align: "center"
        },
        {
          title: "工序编码",
          key: "productionProcessesCode",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        {
          title: "工序",
          key: "productionProcessesName",
          minWidth: 100,
          align: "center",
          resizable: true,
          tooltip: true
        },
        // {
        //     title: "创建时间",
        //     key: "createTime",
        //     minWidth: 100,
        //     align: "center",
        //     resizable: true,
        //     tooltip: true,
        // },
        {
          title: "操作",
          slot: "action",
          fixed: "right",
          minWidth: 180,
          align: "center"
        }
      ],
      loading: false,
      //三级搜索参数
      searchParams: {},

      //一级页面分页参数
      pageNum: 1,
      pageSize: 10,
      total: 0,

      dataArr: [],

      allCheck: false,

      delFaultCodeShowF: false, //是否显示删除弹窗
      pageSizeOption: [10, 20, 30, 40],
      delIds: [],
      selection: [],
      createByOptions: []
    };
  },
  mounted() {
    // this.getTableColumnsWidth(this.columns);
    this.getTableColumnsWidth(this.columns, "orderAdjustmentDeviceInfo");
    this.searchList();
  },
  methods: {
    reset() {
      this.searchParams = {};
      this.changeNum();
    },
    getSearch(params) {
      this.searchParams = JSON.parse(JSON.stringify(params[0]));
      this.pageNum=1;
      this.searchList();
    },
    //分页
    changeNum() {
      this.pageNum = 1;
      this.searchList();
    },
    changePageSize(pageSize) {
      this.pageSize = pageSize;
      this.searchList();
    },
    changePageNum(val) {
      this.pageNum = val;
      this.searchList();
    },
    //查询列表
    searchList() {
      let params = {
        pageNum: this.pageNum,
        pageSize: this.pageSize
      };
      for (let key in this.searchParams) {
        if (this.searchParams[key]) {
          this.$set(params, key, this.searchParams[key]);
        }
      }
      this.axios({
        method: "post",
        url: "/dms/clearLineConfig/productionProcessesPage",
        data: params
      }).then(res => {
        if (res.code === 200) {
          this.dataArr = res.data.records;
          this.total = res.data.total;
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true
          });
        }
      });
    },
    check(row) {
      this.$router.push({
        path: "/lineClean/detail",
        query: {
          productionProcessesCode: row.productionProcessesCode
        }
      });
    },
    deleteOk() {
      this.loading = true;
      let params = { deviceIdList: this.delIds1, moldId: this.id };
      deleteApi(params).then(res => {
        this.loading = false;
        if (res.code === 200) {
          this.changeNum1();
          this.$Message.success("删除成功");
          this.$refs.selection.selectAll(false);
          this.delFaultCodeShowF = false;
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true
          });
        }
      });
    }
  }
};
</script>
      
<style scoped lang="scss">
.ivu-input-number {
  width: -webkit-fill-available;
}

.btn-box {
  padding: 8px 5px !important;
}
</style>